package com.packagetracker.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class DateUtil {
	
	public static String formatDate(final String format, final Date date) {
		return new SimpleDateFormat(format, Locale.getDefault()).format(date);
	}
	
	public static String toDate(final String before, final String after, final String date) {
		try {
			return formatDate(after, new SimpleDateFormat(before, Locale.getDefault()).parse(date));
		}
		catch (ParseException e) {
			return date;
		}
	}
	
}